package priv.menguer.iterator.service.impl;

import priv.menguer.iterator.service.Container;
import priv.menguer.iterator.service.Iterator;

/**
 * @Title NameRepository.java
 * @description TODO
 * @time 2018年10月26日 上午11:10:31
 * @author menguer@126.com
 * @version 1.0
 */
public class NameRepository implements Container {
	public String names[] = { "Robert", "John", "Julie", "Lora" };

	@Override
	public Iterator getIterator() {
		return new NameIterator();
	}

	private class NameIterator implements Iterator {

		int index;

		@Override
		public boolean hasNext() {
			if (index < names.length) {
				return true;
			}
			return false;
		}

		@Override
		public Object next() {
			if (this.hasNext()) {
				return names[index++];
			}
			return null;
		}
	}
}
